package Levels;

import java.util.ArrayList;
import java.util.Collections;

/**
 * Created by:
 * User: Igor Martynovich and Guzenko Igor
 * Date: 14.11.13
 */
public class LevelGenerator {

    public LevelWrapper getLevel(Level level){
         ArrayList<Integer> fullList = generateLevel(level);
         Collections.shuffle(fullList);
         ArrayList<Integer> realLevelList  = new ArrayList<>(level.getCountPerLevel());
         for(int i = 0;i<level.getCountPerLevel();i++){
             realLevelList.add(i, fullList.get(i));
         }

         return new LevelWrapper(realLevelList);
    }

    private ArrayList<Integer> generateLevel(Level level){
        int size = level.getSectionEnd()-level.getSectionStart()+1;
        ArrayList<Integer> levelFullList = new ArrayList<>(size);
        int questionId =level.getSectionStart();
        for(int inndex=0;inndex<size;inndex++){
            levelFullList.add(inndex,questionId);
            questionId++;
        }
        return levelFullList;
    }
}
